package com.tuanzi.blog.interceptpr;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 雄关漫道真如铁，而今迈过从头越
 **/

@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 配置登录拦截器,如果没有user，重定向到首页
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin","/admin/login");
    }
}
